package TestDemo5;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2024-06-10
 * Time: 16:44
 */

/*class Money implements Cloneable{
    public double money = 19.9;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

class Student implements Cloneable {
    public int age;

    public Money m;

    public Student(int age){
        this.age = age;
        this.m = new Money();
    }
    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Student str = (Student) super.clone();
        str.m = (Money) this.m.clone();
        return str;
    }
}
public class Test {
    public static void main(String[] args) throws CloneNotSupportedException{
        Student student1 = new Student(10);
        Student student2 = (Student) student1.clone();
        System.out.println(student1);
        System.out.println(student2);
        System.out.println("================");
        System.out.println(student1.m.money);
        System.out.println(student2.m.money);
        System.out.println("================");
        student2.m.money = 99.8;
        System.out.println(student1.m.money);
        System.out.println(student2.m.money);//浅拷贝
        System.out.println("================");
    }
}



            class Money implements Cloneable{
                public double money = 19.9;

                @Override
                protected Object clone() throws CloneNotSupportedException {
                    return super.clone();
                }
            }

            class Student implements Cloneable {
                public int age;

                public Money m;

                public Student(int age){
                    this.age = age;
                    this.m = new Money();
                }
                @Override
                public String toString() {
                    return "Student{" +
                            "age=" + age +
                            '}';
                }

                @Override
                protected Object clone() throws CloneNotSupportedException {
                    Student str = (Student) super.clone();
                    str.m = (Money) this.m.clone();
                    return str;
                }
            }
            public class Test {
                public static void main(String[] args) throws CloneNotSupportedException{
                    Student student1 = new Student(10);
                    Student student2 = (Student) student1.clone();
                    System.out.println(student1);
                    System.out.println(student2);
                    System.out.println("================");
                    System.out.println(student1.m.money);
                    System.out.println(student2.m.money);
                    System.out.println("================");
                    student2.m.money = 99.8;
                    System.out.println(student1.m.money);
                    System.out.println(student2.m.money);//浅拷贝
                    System.out.println("================");
                }
            }
        }
    }
}*/








interface A{
    void test();
}
public class Test {
    public static void main(String[] args) {
        new A() {
            @Override
            public void test() {
                System.out.println("匿名内部类");
            }
        }.test();
    }
}



/*interface A{
    void test();
}
public class Test {
    public static void main(String[] args) {
        A a = new A(){
            @Override
            public void test() {
                System.out.println("匿部类");
            }
        };
        a.test();
    }
}*/
